﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/admin.master" AutoEventWireup="true" CodeFile="UploadDemo.aspx.cs" Inherits="Admin_UploadDemo" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<asp:Content ID="Content1" ContentPlaceHolderID="sub_menu" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="page_infor" Runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="content" Runat="Server">
    <form runat="server" id="frm">
            <ajaxToolkit:ToolkitScriptManager runat="Server" EnablePartialRendering="true" ID="ScriptManager1" />
         <script type="text/javascript">
             function fillCell(row, cellNumber, text) {
                 var cell = row.insertCell(cellNumber);
                 cell.innerHTML = text;
                 cell.style.borderBottom = cell.style.borderRight = "solid 1px #aaaaff";
             }
             function addToClientTable(name, text) {
                 var table = document.getElementById("<%= clientSide.ClientID %>");
                 var row = table.insertRow(0);
                 fillCell(row, 0, name);
                 fillCell(row, 1, text);
             }

             function uploadError(sender, args) {
                 addToClientTable(args.get_fileName(), "<span style='color:red;'>" + args.get_errorMessage() + "</span>");
             }
             function uploadComplete(sender, args) {
                 var contentType = args.get_contentType();
                 var text = args.get_length() + " bytes";
                 if (contentType.length > 0) {
                     text += ", '" + contentType + "'";
                 }
                 addToClientTable(args.get_fileName(), text);
             }
        </script>

        <div class="demoarea">
                <div class="demoheading">AsyncFileUpload Demonstration</div>
                Click '<i>Select File</i>' for asynchronous uploading.
                <br /><br />
        
                <ajaxToolkit:AsyncFileUpload
                    OnClientUploadError="uploadError" OnClientUploadComplete="uploadComplete" 
                    runat="server" ID="AsyncFileUpload1" Width="400px" UploaderStyle="Modern" 
                    UploadingBackColor="#CCFFFF" ThrobberID="myThrobber"
                     />&nbsp;<asp:Label runat="server" ID="myThrobber" style="display:none;" ><img align="absmiddle" alt="" src="uploading.gif" /></asp:Label>
                <div><strong>The latest Server-side event:</strong></div>
                <asp:Label runat="server" Text="&nbsp;" ID="uploadResult" />
                <br /><br />
                <div><strong>Client-side events:</strong></div>
                <table style="border-collapse: collapse; border-left: solid 1px #aaaaff; border-top: solid 1px #aaaaff;" runat="server" cellpadding="3" id="clientSide" />
        </div>
        <div class="demobottom"></div>
        </form>
</asp:Content>

